home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 3652 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.8 KB  |  78 lines

  1. Newsgroups: comp.lang.c
  2. Path: in1.uu.net!tellab5!news
  3. From: Joe Toth <toth@tellabs.com>
  4. Subject: Re: Transparent file copy??
  5. X-Nntp-Posting-Host: sunh25
  6. Content-Type: text/plain; charset=us-ascii
  7. Message-ID: <1996Jan30.151917.713@tellab5.tellabs.com>
  8. Sender: news@tellab5.tellabs.com (News)
  9. Content-Transfer-Encoding: 7bit
  10. Organization: Tellabs Operations, Inc.
  11. References: <Pine.A32.3.91.960129223003.178909A-100000@black.weeg.uiowa.edu>
  12. Mime-Version: 1.0
  13. Date: Tue, 30 Jan 1996 15:19:17 GMT
  14. X-Mailer: Mozilla 1.1 (X11; U; SunOS 4.1.3 sun4c)
  15. X-Url: news:Pine.A32.3.91.960129223003.178909A-100000@black.weeg.uiowa.edu
  16.  
  17. The Amorphous Mass <robinson@blue.weeg.uiowa.edu> wrote:
  18. >On Tue, 30 Jan 1996, Shawn L. Bradley wrote:
  19. >
  20. >> How do I transparently copy files from one drive & directory to
  21.                           ^^^^                ^^^^^
  22. >> another in DOS.  I don't want to use the system() function because it
  23.    ^^^^^^^
  24. >> interferes with the windows my app creates.  I'm using MSVC++ 1.52.
  25. >> Any help would be greatly appreciated.
  26. >
  27. >  You might try the rename() function (in <stdio.h>).  It takes as 
  28.                      ^^^^^^^^
  29.  
  30. Nope, no way.
  31. If it works, you no longer have the original..
  32.  
  33. And it won't always work - see below.
  34.  
  35. >parameters two strings which are contain the old filename and the new 
  36. >filename and returns non-zero if it fails to rename the file.  Note that 
  37. >a "filename" can include a path, so
  38.  
  39. >
  40. >rename("C:\\FOO\\BAR.BAT", "C:\\BLECH\\BLORCH\\YUK.BAT");
  41. >
  42. >will attempt to rename C:\FOO\BAR.BAT to C:\BLECH\BLORCH\YUK.BAT.
  43.  
  44. Which fails miserably if you are trying to copy from one file
  45. system to another (say, hard drive to a floppy)
  46.  
  47. Try;
  48.  
  49.   rename("C:\\FOO\\BAR.BAT", "A:\\BLECH\\BLORCH\\YUK.BAT");
  50.  
  51. It will fail...........
  52.  
  53. If you do intend to move the file from one drive to another, you have
  54. to 'copy' it first then delete the original.  No other way around it.
  55.  
  56. if you want to do it quickly without using 'system()', you will have
  57. to write your own code to do it.  It's not difficult.
  58.  
  59. >
  60. >  Of course you can also pass char * or char [] variables to rename() if 
  61. >you want to build the pathnames dynamically.
  62. >
  63. >/**James Robinson***********************            
  64. >  "An important goal of almost every graphics program is to draw pictures on
  65. > the screen."    -- Neider, Davis & Woo, _OpenGL_Programming_Guide_, Chapter 10
  66. >                                       *************james-robinson@uiowa.edu**/
  67.  
  68. -- 
  69.   _  _  ___  --------------------------+---------------------------------
  70.   | / _  |    Joseph G. Toth Jr.       | Tellabs Operations, Inc.  
  71. \_| \_/  |                             | toth@tellabs.com
  72.  
  73. > Every program has at least one bug and can be shortened by at least
  74. > one instruction -- from which, by induction, it is evident that every
  75. > program can be reduced to one instruction that does not work.
  76. >                       -- Ken Arnold
  77.  
  78.